<?php
if(!class_exists('MAIN_Controller_Action')) Zend_Loader :: loadClass('MAIN_Controller_ActionFront');
class Front_TransectionController extends MAIN_Controller_ActionFront {
    public function patransectionAction() {
    	$view = $this->_getView();
    	$today = getToday();
    	$view->assign("today",$today);
    	$view->assign("defaultdate",date('d/m/Y'));
    	$view->output('transection/pa_transection.tpl');
    }
    public function loadtplAction(){
    	$params   = $this->getParams();
    	$view = $this->_getView();
    	$view->output('transection/'.$params['tpl'].'.tpl');
    }
    public function getpreauthtranlistAction() {
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$view = $this->_getView();
    	if(!class_exists('Zend_Auth'))Zend_loader :: loadClass('Zend_Auth');
    	$auth = Zend_Auth :: getInstance();
    	$identity = $auth->getIdentity();
    	$data = $generic->getpreauthtranlist($params,$identity->userid);
    	$view->assign("data",$data);
    	$data['htmls'] = $view->outputhtml('ajax/_view_pa_tran_list.tpl');
    	$this->_helper->json($data);
    }
    public function paymenttransectionAction() {
    	$view = $this->_getView();
    	$today = getToday();
    	$view->assign("today",$today);
    	$view->assign("defaultdate",date('d/m/Y'));
    	$view->output('transection/payment_transection.tpl');
    }
    public function getpaymenttranlistAction() {
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$view = $this->_getView();
    	if(!class_exists('Zend_Auth'))Zend_loader :: loadClass('Zend_Auth');
    	$auth = Zend_Auth :: getInstance();
    	$identity = $auth->getIdentity();
    	$data = $generic->getpaymenttranlist($params,$identity->userid);
    	$view->assign("data",$data);
    	$data['htmls'] = $view->outputhtml('ajax/_view_payment_tran_list.tpl');
    	$this->_helper->json($data);
    }
    public function preauthdetailAction(){
    	$params   = $this->getParams();
    	$generic = System_Controller::getGeneric("preauthorize","front");
    	$view = $this->_getView();
    	$today = getToday();
    	$preauthId = $generic->getPreauthId();
    	$policyData = $generic->getPolicyById($params['policy_id']);
    	$paInfo = $generic->getPaInfo($params['policy_id']);
    	$paClaimData = $generic->getPaClaim($params['policy_id']);
    	if($policyData['customer_type_desc'] == 'PA'){
    		$tpl = 'preauthorize/pa_detail.tpl';
    	}
    	else{
    		$erClaimData = $generic->getErClaim($params['policy_no']);
    		$PlanData = $generic->getPlan2catByPlanId($policyData['plan_id']);
    		$view->assign("erClaimData",$erClaimData);
    		$view->assign("PlanData",$PlanData);
    		$tpl = 'preauthorize/health_detail.tpl';
    	}
    	$view->assign("APP_URL",APP_URL);
    	$view->assign("policy_id",$params['policy_id']);
    	$view->assign("today",$today);
    	$view->assign("preauthId",$preauthId);
    	$view->assign("policyData",$policyData);
    	$view->assign("paInfo",$paInfo);
    	$view->assign("paClaimData",$paClaimData);
    	$view->assign("title",'Pre-authorize Transection');
    	$view->output($tpl);
    }
    public function paymentpaAction(){
    	if(!class_exists('Zend_Auth'))Zend_loader :: loadClass('Zend_Auth');
    	$params   = $this->getParams();
    	$generic = $this->getGeneric();
    	$payment_generic = System_Controller::getGeneric("payment","front");
    	$view = $this->_getView();
    	$today = getToday();
    	$payment_datetime	=	date('Y-m-d H:i:s');
    	$auth = Zend_Auth :: getInstance();
    	$identity = $auth->getIdentity();
    	$payment_detail = $generic->getPaymentDetail($params['payment_id']);
    	$preauthData = $payment_generic->getPreAuthById($payment_detail['preauth_id'],$identity->userid);
    	$policyData = $payment_generic->getPolicyById($preauthData['0']['policyid']);
    	$claimGetCover	=	$payment_generic->getClaimCover();
    	
    	$img = 'title_pa.png';
    	$view->assign("img",$img);
    	$view->assign("APP_URL",APP_URL);
    	$view->assign("paymentId",$params['payment_id']);
    	$view->assign("preauthData",$preauthData['0']);
    	$view->assign("today",$today);
    	$view->assign("payment_datetime",$payment_datetime);
    	$view->assign("policyData",$policyData);
    	$view->assign("claimGetCover",$claimGetCover);
    	$view->assign("payment_detail",$payment_detail);
    	$view->assign("title",'Payment Transection');
    	$view->output('transection/payment_pa.tpl');
    }
}
?>